﻿#ifndef XFUNCTION_H
#define XFUNCTION_H

#include "xnamespace.h"
#include "xcoil.h"
#include "xregister.h"
#include "xpushbuttonfourarithmetic.h"
#include <QDebug>

class XFunction
{
public:
    XFunction();
    explicit XFunction(XCoil *coil);
    explicit XFunction(XCoil *coilA, XCoil *coilB);
    explicit XFunction(XRegister *registerA, double value);
    explicit XFunction(XRegister *registerA, XRegister *registerB);
    explicit XFunction(QList<XRegister*> listA, QList<XRegister*> listB);
    explicit XFunction(XPushButtonFourArithmetic *pushButtonFourArithmetic);

    ~XFunction();

public:
    //coilFunc
    void setCoil();
    void resetCoil();
    void reverseCoil();
    void copyCoil();

    //registerFunc
    void setRegister();
    void copyRegister();
    void copyRegisterBlock();
    void fourArithmetic();

    //加一些set函数，匹配默认构造函数的使用

private:
    XCoil *xCoilSingle = nullptr;
    XCoil *xCoilSource = nullptr;
    XCoil *xCoilDestination = nullptr;

    XRegister *xRegisterSingle = nullptr;
    XRegister *xRegisterSource = nullptr;
    XRegister *xRegisterDestination = nullptr;
    double setValue;
    int registerNum;

    QList<XRegister*> xRegisterListSource;
    QList<XRegister*> xRegisterListDestination;

    XPushButtonFourArithmetic *pushButtonFourArithmetic = nullptr;
};

//声明XFunction的函数指针
typedef void (XFunction::*Function)(void);

#endif // XFUNCTION_H
